package com.gaoxinfu.demo.spring.cloud.jpa.starter.controller;

import com.gaoxinfu.demo.spring.cloud.jpa.starter.entity.Money;
import com.gaoxinfu.demo.spring.cloud.jpa.starter.repository.MoneyRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @Description:
 * @Author: gaoxinfu
 * @Date: 2021-06-18 08:25
 */
@RestController
@RequestMapping(value = "/money")
public class MoneyController {

    @Resource
    MoneyRepository moneyRepository;

    @GetMapping (value = "/findById")
    public Money findById(Integer id){
        Optional<Money> optional =  moneyRepository.findById(1);
        if (optional.isPresent()){
            return optional.get();
        }
        return null;
    }
}
